//
//  TomorrowViewController.m
//  BasketballClub
//
//  Created by lanou3g on 16/1/6.
//  Copyright © 2016年 孙鸿吉. All rights reserved.
//

#import "TomorrowViewController.h"
#import "LiveInfoView.h"
#import "LiveTableViewCell.h"
#import "LiveHandle.h"
#import "LiveModel.h"
#import <MJRefresh.h>
#import "WebViewController.h"
@interface TomorrowViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)LiveInfoView *liveInfoView;
@end

@implementation TomorrowViewController

-(void)loadView{
    self.liveInfoView = [[LiveInfoView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH)];
    self.view = self.liveInfoView;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.liveInfoView.tableview.delegate = self;
    self.liveInfoView.tableview.dataSource = self;
    [self.liveInfoView.tableview registerClass:[LiveTableViewCell class] forCellReuseIdentifier:@"LiveTableViewCellTomorrow"];
    [[LiveHandle sharedLiveHandle] GetTomorrowDataFromNetWorkWithBlock:^(BOOL isFinished) {
        [self.liveInfoView.tableview reloadData];
        
    }];
//    //调用刷新的方法
//    [self upData];
    self.liveInfoView.tableview.tableFooterView = [[UIView alloc]init];
    
}




#pragma mark - tableViewDataSoucre
//rows的个数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [LiveHandle sharedLiveHandle].liveTomorrowDataArray.count;
}
#pragma mark - cell的创建和重用
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LiveTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LiveTableViewCellTomorrow"];
    if ([LiveHandle sharedLiveHandle].liveTomorrowDataArray.count) {
        LiveModel *model =[LiveHandle sharedLiveHandle].liveTomorrowDataArray[indexPath.row];
        [cell setCellDataFromLiveModel:model];
        
           }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return cell;

   
}
#pragma mark  - cell的高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 190*LAYOUT_SIZE_HEIGHT;
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    [LiveHandle sharedLiveHandle].liveTomorrowDataArray = nil;
}





//#pragma mark - 下拉刷新
//-(void)upData
//{
//    MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshAction)];
//    self.tomorrowTableView.mj_header = header;
//    [self.tomorrowTableView.mj_header beginRefreshing];
//
//
//}
//#pragma mark  - 刷新执行的方法
//-(void)refreshAction
//{
//
//    [LiveHandle sharedLiveHandle].liveTomorrowDataArray = nil;
//    __weak typeof(self) weakSlef = self;
//    [[LiveHandle sharedLiveHandle] GetTomorrowDataFromNetWorkWithBlock:^(BOOL isFinished) {
//        if (isFinished) {
//            
//            [weakSlef.tomorrowTableView reloadData];
//            
//        }else{
//
//            [[LiveHandle sharedLiveHandle] GetTomorrowDataFromNetWorkWithBlock:^(BOOL isFinished) {
//
//            }];
//        }
//        [weakSlef.tomorrowTableView.mj_header endRefreshing];
//    }];
//
//
//}




@end
